package com.example.administrator.xposedtest2;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    private final String Uname = "admin";
    private final String Passw = "admin";

    private EditText etU , etP;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        etU = (EditText)findViewById(R.id.editText);
        etP = (EditText) findViewById(R.id.editText2);
        findViewById(R.id.btnStart).setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v){
                Intent i = new Intent(MainActivity.this,TheActivity.class);
                Bundle b = new Bundle();
                b.putString("uname",etU.getText().toString());
                b.putString("passwd",etP.getText().toString());
                i.putExtras(b);

                if (isOK(etU.getText().toString(),etP.getText().toString())){
                    Toast.makeText(MainActivity.this,"Login Success !" , Toast.LENGTH_SHORT).show();
                    startActivity(i);
                }else{
                    Toast.makeText(MainActivity.this,"Login Wrong Check And Again !" , Toast.LENGTH_SHORT).show();
                }
            }
        });
    }
    private boolean isOK(String uname, String pass) {
        return uname.equals(Uname)&&pass.equals(Passw);
    }
}
